const promises = [
  new Promise((resolve) => setTimeout(resolve, 1000, "one")),
  new Promise((resolve) => setTimeout(resolve, 2000, "two")),
  new Promise((resolve) => setTimeout(resolve, 3000, "three")),
];

Promise.race(promises)
  .then((value) => console.log(value))
  .catch((error) => console.error(error));
